package com.xindacloud.sms.adapter.service.notify;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


@Component
public class NotifyServiceFactory {

    private final Map<String, INotifyService> iNotifyServiceStrategyMap = new ConcurrentHashMap<>();

    @Autowired
    public NotifyServiceFactory(Map<String, INotifyService> iNotifyServiceStrategyMap) {
        this.iNotifyServiceStrategyMap.clear();
        iNotifyServiceStrategyMap.forEach(this.iNotifyServiceStrategyMap::put);
    }

    public void getService(String type, String content) {
        final String routeService = type.concat("NotifyService");
        iNotifyServiceStrategyMap.get(routeService).perform(content);
    }
}
